package org.snake.demo.mvc.action;

import org.snake.demo.service.IDemoService;
import org.snake.mvcframework.annotation.RAYAutowired;
import org.snake.mvcframework.annotation.RAYController;
import org.snake.mvcframework.annotation.RAYRequestMapping;
import org.snake.mvcframework.annotation.RAYRequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RAYController
@RAYRequestMapping("demo")
public class DemoAction
{

    @RAYAutowired
    private IDemoService demoService;

    private IDemoService demoService2;

    @RAYRequestMapping("query")
    public void query(HttpServletRequest req, HttpServletResponse resp,
            @RAYRequestParam("name") String name, @RAYRequestParam("id") String id,
            @RAYRequestParam("sex") String sex, @RAYRequestParam("addr") String addr)
    {
//        String result = demoService.get(name);
        String result = "My name is " + name + ",id = " + id + ",addr = " + addr + ",sex = " + sex;

        try
        {
            resp.getWriter().write(result);
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }

    }

}
